<template>
  <div>
    <!--  <el-container style="height: 100%">-->
    <router-view name="top"></router-view>
    <el-container style="">
      <router-view name="aside" @chooseModel="chooseModel" @manageStrategy="manageStrategy" ref="changeCSS"></router-view>
      <el-main>
        <!--        <router-view/>-->
        <router-view></router-view>
        <manage-strategies v-if="showStrategiesModel" @closeModel="closeModel"></manage-strategies>
        <manage-currency-strategies v-if="showCurrencyStrategiesModel"  :device-type-id="deviceTypeId" :device-type-name="deviceTypeName" :block-id="blockId" @closeModel="closeModel"></manage-currency-strategies>
        <manage-orders v-if="showOrdersModel" @closeModel="closeModel"></manage-orders>
        <global-control v-if="showGlobalControl" @closeModel="closeModel"></global-control>
        <manage-dept v-if="showDeptModel" @closeModel="closeModel"></manage-dept>

      </el-main>
    </el-container>
    <!--  </el-container>-->
  </div>
</template>

<script>
  import manageStrategies from './setting/manageStrategies'
  import manageCurrencyStrategies from './setting/manageCurrencyStrategies'
  import manageOrders from './setting/manageOrders'
  import globalControl from './setting/globalControl'
  import manageDept from "./setting/manageDept";

  export default {
    name: 'homePage',
    components: {
      manageStrategies,
      manageOrders,
      globalControl,
      manageDept,
      manageCurrencyStrategies
    },
    data () {
      return {
        count: 0,
        cookieCode: '',
        showStrategiesModel: false,
        showOrdersModel: false,
        showCurrencyStrategiesModel:false,
        showGlobalControl: false,
        showDeptModel: false,
        deviceTypeId: '',
        deviceTypeName: ''
      }
    },
    methods: {
      chooseModel (controlName) {
        console.log("test")
        if (controlName === 'manageStrategies') {
          this.showStrategiesModel = true
        } else if(controlName === 'manageCurrencyStrategies'){
          this.showCurrencyStrategiesModel= true
        } else if (controlName === 'manageOrders') {
          this.showOrdersModel = true
        } else if (controlName === 'globalControl') {
          this.showGlobalControl = true
        } else if (controlName === 'manageDept') {
          this.showDeptModel = true
        }
    },

      manageStrategy(deviceTypeId,deviceTypeName){
        if(deviceTypeName == "空调"){
          this.showStrategiesModel = true
        }else {
          this.deviceTypeId = deviceTypeId
          this.deviceTypeName = deviceTypeName
          this.showCurrencyStrategiesModel= true
        }
      },

      updateNav () {
        this.$refs.changeCSS.initLeftNav()
      },

      closeModel () {
        this.showStrategiesModel = false
        this.showCurrencyStrategiesModel = false
        this.showOrdersModel = false
        this.showGlobalControl = false
        this.showDeptModel = false
        // this.$emit('chooseModel')
        this.$refs.changeCSS.changeCss()
      },

      getUrlParam (sUrl, sKey) {
        var left = sUrl.indexOf('=') + 1
        var parasString = sUrl.slice(left)
        console.log(parasString)
        return parasString
      }
    },
  }
</script>

<style scoped>
  .el-main {
    padding: 0;
    left: 180px;
    background: #eee;
    position: absolute;
    top: 80px;
    bottom: 0;
    right: 0;
    min-width: 844px;
    overflow: hidden;
  }
</style>
